﻿using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace LunarSF.SHomeWorkshop.LunarMarkdownEditor
{
    /// <summary>
    /// VimKeySelector.xaml 的交互逻辑
    /// </summary>
    public partial class VimKeySelector : MetroWindow
    {
        public VimKeySelector()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 默认 LeftShift。如果没有选择，返回null。
        /// </summary>
        public Key? VimKey
        {
            get
            {
                if (rbtnLeftCtrl.IsChecked == true) return Key.LeftCtrl;
                if (rbtnLeftShift.IsChecked == true) return Key.LeftShift;
                if (rbtnRightCtrl.IsChecked == true) return Key.RightCtrl;
                if (rbtnRightShift.IsChecked == true) return Key.RightShift;
                if (rbtnRightShift.IsChecked == true) return Key.None;
                return null;
            }
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
            this.Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }

        private void RBtn_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            this.DialogResult = true;
            this.Close();
        }
    }
}
